package com.example.markingsystem.controller;

import com.example.markingsystem.bean.localteacher;
import com.example.markingsystem.bean.openidrecord;
import com.example.markingsystem.mapper.LocalteacherMapper;
import com.example.markingsystem.mapper.LoginMapper;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpSession;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class Localteachercontroller {

    @Resource
    private LocalteacherMapper localteacherMapper;

    @Resource
    private LoginMapper loginMapper;

    @RequestMapping("addLocalteacherInfo")
    public String addGraduateInfo(@Param("name") String name , @Param("workid") String workid , @Param("telephone") String telephone, @Param("region") String region, HttpSession session){
        localteacher l = new localteacher();
        String nowuseridcode = (String) session.getAttribute("userlogin");
        l.setIdcode(nowuseridcode);
        l.setName(name);
        l.setWorkid(workid);
        l.setTelephone(region+telephone);
        localteacherMapper.addInfo(l);

        String nowopenid = (String) session.getAttribute("nowopenid");
        System.out.println(nowopenid+"在这里也传到了吗");
        openidrecord nowrecord = new openidrecord();
        nowrecord.setIdcode(nowuseridcode);
        nowrecord.setOpenid(nowopenid);
        loginMapper.insertOpenidRecord(nowrecord);

        return "test";
    }

    @RequestMapping("toAddLocalteacherInfo")
    public String toLocalteacherInfo(){
        return "benxiaolaoshiInfo";
    }
}
